<?php
require_once './model/works.php';
$id_work=$_GET['id'];
$md_works=new Works();
$params=array(
    'id_works'=>$id_work
);
$works=$md_works->select($params);

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<table style="margin:  0 auto;text-transform: capitalize;">
        <tr>
            <td>Name</td>
            <td><input type="text" name="name" style="width: 600px; height: 50px;" value="<?php echo $works[0]["name"] ?>"></td>
        </tr>
        <tr>
            <td> <input type="file" name="file" id="file"></td>
            <td><input type="submit" name="submit" value="Upload">  </td>
        </tr>
</table>
<?php
if(isset($_POST['submit'])){
    if(($_FILES['file']['type']=='image/png')||
      (($_FILES['file']['type']=='image/png'))){
    
      move_uploaded_file($_FILES['file']['tmp_name'],"public/images/".$_FILES["file"]["name"]);}
    $work=array(
        'id'=>$id_work,
        'name'=>$_POST['name'],
        'image'=>$_FILES['file']['name']
    );
    $md_works->updates($work);
}
?>
